/*
 * @lc app=leetcode.cn id=1491 lang=javascript
 *
 * [1491] 去掉最低工资和最高工资后的工资平均值
 */

// @lc code=start
/**
 * @param {number[]} salary
 * @return {number}
 */
var average = function (salary) {
  let [max] = salary;
  let [min] = salary;
  let sum = 0;
  salary.forEach(s => {
    max = Math.max(max, s);
    min = Math.min(min, s);
    sum += s;
  })
  return (sum - max - min) / (salary.length - 2);
};
// @lc code=end

